package com.neutch.test;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class sjxm_1 {
    public static void main(String[] args) throws ClassNotFoundException, SQLException {
        //第一步加载驱动
        Class.forName("com.mysql.cj.jdbc.Driver");
        //定义连接url
        Connection con= DriverManager.getConnection("jdbc:mysql://localhost:3306/test","root","123456");
        Statement statement=con.createStatement();
            String  sql_1="update users set birthday = NOW() where name='张三' ";
            String  sql_2="delete  from users where name='李四'";
            String sql_3="select * from users where birthday > 1987";
            statement.executeUpdate(sql_1);
            statement.executeUpdate(sql_2);
            statement.executeQuery(sql_3) ;

//        String sql="select * from users";
      ResultSet res= statement.executeQuery(sql_3);
       while(res.next()){
           System.out.print(res.getString(1)+" ");
           System.out.print(res.getString(2)+" ");
           System.out.print(res.getString(3)+" ");
           System.out.print(res.getString(4)+" ");
           System.out.print(res.getString(5)+ " ");
           System.out.println();


       }
    }
}
